﻿using PersistObject.Common.Structures;
using PersistObject.Common.Structures.Mapping;
using PersistObject.Common.Structures.Schema;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PersistObject.Common.Criteria
{
    /// <summary>
    /// Represent a criteria which perform GROUP BY clause and then compare with the aggregate value
    /// </summary>
    public class ExistsGroupCriteria : BaseCriteria
    {
        /// <summary>
        /// Indicate the grouped table
        /// </summary>
        public GroupTable GroupTable { get; private set; }
        /// <summary>
        /// Indicate the links between inner tables and outer tables
        /// </summary>
        public GroupTableLink[] Links { get; private set; }
        /// <summary>
        /// Indicate the criteria in the grouped table
        /// </summary>
        public BaseCriteria GroupTableCriteria { get; private set; }
        /// <summary>
        /// Indicate the criteria for comparing with the aggregate value
        /// </summary>
        public BaseCriteria AggregateCriteria { get; private set; }

        /// <summary>
        /// The constructor of EXISTS GROUP criteria
        /// </summary>
        /// <param name="groupTable">Indicate the grouped table</param>
        /// <param name="links">Indicate the links between inner tables and outer tables</param>
        /// <param name="groupTableCriteria">Indicate the criteria in the grouped table</param>
        /// <param name="aggregateCriteria">Indicate the criteria for comparing with the aggregate value</param>
        public ExistsGroupCriteria(GroupTable groupTable, GroupTableLink[] links, 
            BaseCriteria groupTableCriteria, BaseCriteria aggregateCriteria)
        {
            GroupTable = groupTable;
            Links = links;
            GroupTableCriteria = groupTableCriteria;
            AggregateCriteria = aggregateCriteria;
        }
    }
}
